package com.atguigu.bean;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.NumberFormat;

import javax.validation.constraints.*;
import java.util.Date;

public class Employee {

	private Integer id;

	// 数据校验：@NotEmpty不为空
	@NotEmpty(message = "不能为空！")
	// 数据校验：@Length字符限制(min=6最少6个字符，max=18最多不超过18个字符)
	@Length(min = 6,max = 18,message = "长度必须在6到18个字符之间")
	private String lastName;
	// 数据校验：@Email必须为Email格式
	@Email(message = "邮箱格式不正确")
	private String email;
	//1 male, 0 female
	private Integer gender;

	/*	【数据格式化】
	例如：前端页面的金钱数据是 ￥9,999,999.98
	我们后端为了配合前端的数据，则把金钱的格式化为#,###,###.##格式
	@NumberFormat(pattern = "#,###,###.##")
	private Double salary;
	 */

	// 日期格式化
	@DateTimeFormat(pattern = "yyyy-mm-dd")
	// 数据校验：@Past必须是一个过去的时间
	// 数据校验：@Future必须是一个未来的时间
	@Past
	@JsonFormat(pattern = "yyyy-mm-dd")
	private Date birth;

	@JsonIgnore
	private Department department;

	@Override
	public String toString() {
		return "Employee{" +
				"id=" + id +
				", lastName='" + lastName + '\'' +
				", email='" + email + '\'' +
				", gender=" + gender +
				", birth=" + birth +
				", department=" + department +
				'}';
	}

	public Date getBirth() {
		return birth;
	}

	public void setBirth(Date birth) {
		this.birth = birth;
	}

	public Employee(Integer id, String lastName, String email, Integer gender, Date birth, Department department) {
		this.id = id;
		this.lastName = lastName;
		this.email = email;
		this.gender = gender;
		this.birth = birth;
		this.department = department;
	}

	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Integer getGender() {
		return gender;
	}

	public void setGender(Integer gender) {
		this.gender = gender;
	}

	public Department getDepartment() {
		return department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}


	public Employee() {
	}


}
